package com.example.test.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RabbitMqConfig {

    /***注入**/

    @Bean
    Queue queue1 (){
        return new Queue(RabbitMqConst.WARN_DIRECT_QUEUE,true);
    }

    @Bean
    Queue queue2 (){
        return new Queue(RabbitMqConst.WARN_ORDER_DIRECT_QUEUE,true);
    }

    @Bean
    DirectExchange exchange (){
        return new DirectExchange(RabbitMqConst.DEMO_EXCHANGE,true,false);
    }

    /**绑定**/

    @Bean
    Binding binding1(){
        return BindingBuilder.bind(queue1()).to(exchange()).with(RabbitMqConst.WARN_ROUTING_KEY);
    }

    @Bean
    Binding binding2(){
        return BindingBuilder.bind(queue2()).to(exchange()).with(RabbitMqConst.WARNORDER_ROUTING_KEY);
    }


}
